package com.ruoyi.web.controller.ydz;

import java.util.List;

import com.ruoyi.web.domain.ExaminationNews;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.JapanNews;
import com.ruoyi.web.service.IJapanNewsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日本看病新闻Controller
 * 
 * @author drx
 * @date 2025-05-19
 */
@Controller
@RequestMapping({"/ydz/japanNews","/api/japanNews"})
@Api(tags = "日本看病新闻")
public class JapanNewsController extends BaseController
{
    private String prefix = "ydz/japanNews";

    @Autowired
    private IJapanNewsService japanNewsService;

    @RequiresPermissions("ydz:japanNews:view")
    @GetMapping()
    public String japanNews()
    {
        return prefix + "/japanNews";
    }

    /**
     * 查询日本看病新闻列表
     */
    @RequiresPermissions("ydz:japanNews:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询日本看病新闻列表")
    public TableDataInfo list(JapanNews japanNews)
    {
        startPage();
        List<JapanNews> list = japanNewsService.selectJapanNewsList(japanNews);
        return getDataTable(list);
    }

    @PostMapping("/getJapanNewslist")
    @ResponseBody
    @ApiOperation("查询日本看病新闻列表")
    public TableDataInfo getJapanNewslist(@RequestBody JapanNews japanNews)
    {
        startPage();
        List<JapanNews> list = japanNewsService.selectJapanNewsList(japanNews);
        return getDataTable(list);
    }

    /**
     * 导出日本看病新闻列表
     */
    @RequiresPermissions("ydz:japanNews:export")
    @Log(title = "日本看病新闻", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出日本看病新闻列表")
    public AjaxResult export(JapanNews japanNews)
    {
        List<JapanNews> list = japanNewsService.selectJapanNewsList(japanNews);
        ExcelUtil<JapanNews> util = new ExcelUtil<JapanNews>(JapanNews.class);
        return util.exportExcel(list, "日本看病新闻数据");
    }

    /**
     * 新增日本看病新闻
     */
    @GetMapping("/add")
    @ApiOperation("新增日本看病新闻")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日本看病新闻
     */
    @ApiOperation("新增保存日本看病新闻")
    @RequiresPermissions("ydz:japanNews:add")
    @Log(title = "日本看病新闻", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JapanNews japanNews)
    {
        return toAjax(japanNewsService.insertJapanNews(japanNews));
    }

    /**
     * 修改日本看病新闻
     */
    @ApiOperation("修改日本看病新闻")
    @RequiresPermissions("ydz:japanNews:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JapanNews japanNews = japanNewsService.selectJapanNewsById(id);
        mmap.put("japanNews", japanNews);
        return prefix + "/edit";
    }

    /**
     * 修改保存日本看病新闻
     */
    @ApiOperation("修改保存日本看病新闻")
    @RequiresPermissions("ydz:japanNews:edit")
    @Log(title = "日本看病新闻", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JapanNews japanNews)
    {
        return toAjax(japanNewsService.updateJapanNews(japanNews));
    }

    /**
     * 删除日本看病新闻
     */
    @ApiOperation("删除日本看病新闻")
    @RequiresPermissions("ydz:japanNews:remove")
    @Log(title = "日本看病新闻", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(japanNewsService.deleteJapanNewsByIds(ids));
    }

    /**
     * 其他新闻类tdk配置
     */
    @ApiOperation("其他新闻类tdk配置")
    @RequiresPermissions("ydz:japanNewsTdk:tdkSet")
    @GetMapping("/tdkEdit")
    public String tdkEdit()
    {
        return prefix + "/japanSet";
    }

    @ResponseBody
    @PostMapping("/editState")
    public AjaxResult editState(@RequestBody JapanNews japanNews){
        return toAjax(japanNewsService.updateJapanNews(japanNews));
    }
}
